	/* 
	 * JTable empleados
	 */
	$(document).ready(function() {              
	    //setup the jtable that will display the results
	    $('#EmpleadosTableContainer').jtable({
	        title: ' ',
	        selecting: true, //Enable selecting 
	        paging: true, //Enable paging
	        pageSize: 10, //Set page size (default: 10)
	        sorting: true, //Enable sorting
            defaultSorting: 'Nombre ASC', //Set default sorting
	        actions: {
	        	/*listAction: function (postData, jtParams) {
                    console.log("Loading from custom function...");
                    return $.Deferred(function ($dfd) {
                        $.ajax({
                            url: 'empleados/getEmpleados?jtStartIndex=' + jtParams.jtStartIndex + '&jtPageSize=' + jtParams.jtPageSize,
                            type: 'GET',
                            dataType: 'json',
                            success: function (data) {
                                $dfd.resolve(data);
                            },
                            error: function () {
                                $dfd.reject();
                            }
                        });
                    });
                },	*/        	
                /*createAction: function (postData) {
                    console.log("creating from 	custom function...");
                    return $.Deferred(function ($dfd) {
                        $.ajax({
                            url: 'empleados/addEmpleado',
                            type: 'POST',
                            dataType: 'json',
                            data: postData,
                            success: function (data) {
                                $dfd.resolve(data);
                            },
                            error: function () {
                                $dfd.reject();
                            }
                        });
                    });
                },*/
	        	listAction: 'empleados/getEmpleados',
                createAction: 'empleados/addEmpleado',
	            updateAction: 'empleados/updateEmpleado',
	            viewAction: 'true',
	        },
	        fields: {
	        	EmpleadoId: {
	                title: 'Usuario',
	                width: '20%',
	                inputClass : 'validate[required]',
	    	        sorting: true,
	            },
	            Nombre: {
	                title: 'Nombre',
	                width: '35%',
	                sorting: false

	            },
	            Apellido: {
	                title: 'Apellido',
	                width: '35%',
	                sorting: false
	            },
	            Estado: {
	                title: 'Estado',
	                width: '10%',
	                type: 'checkbox',
	                values: { 'false': 'Inactivo', 'true': 'Activo' },
	                defaultValue:'true',
	                sorting: false
	            },
	            EmpUserId: {
	                key: true,
	                visibility: 'hidden'
	            },
	            Centroid: {
	            	create: false,
	            	edit: false,
	            	view: false,
	                visibility: 'hidden'
	            }
	        },
	        
	      //Initialize validation logic when a form is created
            formCreated: function (event, data) {
                data.form.validationEngine();
            },
            //Validate form when it is being submitted
            formSubmitting: function (event, data) {
                return data.form.validationEngine('validate');
            },
            //Dispose validation logic when form is closed
            formClosed: function (event, data) {
                data.form.validationEngine('hide');
                data.form.validationEngine('detach');
            },
	        //Register to selectionChanged event to hanlde events                                     
	        recordAdded: function(event, data){
	            //after record insertion, reload the records
	            $('#EmpleadosTableContainer').jtable('load');
	        },
	        recordUpdated: function(event, data){
	            //after record updation, reload the records
	            $('#EmpleadosTableContainer').jtable('load');
	        },	        
	        recordsLoaded: function(event, data) {
		        for(var i = 0;i<data.records.length;i++){
	        	   if (data.records[i].EmpUserId==data.records[i].Centroid){
	        		   $row = $('#EmpleadosTableContainer').jtable('getRowByKey', data.records[i].EmpUserId);
	        		   $row.find('.jtable-edit-command-button').hide();
	        	   }
		        }
	        },
	    });
	    $('#EmpleadosTableContainer').jtable('load');              
	                
	});


	 /*createAction: function (postData) {
        console.log("creating from custom function...");
        var json = {"empleadoId":"prueba", "nombre": "nombrepruebe", "apellido": "apellidoprueba"}
        return $.Deferred(function ($dfd) {
            $.ajax({
                url:  $("#contextPath").val()+"/private/control/empleados/addEmpleado",
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(json),
                success: function (data) {
                    $dfd.resolve(data);
                },
                error: function () {
                    $dfd.reject();
                }
            });
        });
    },*/